package com.pengshun.modules.security;

import com.pengshun.modules.Interceptor.AuthorizationInterceptor;
import com.pengshun.modules.api.mapper.PsUserInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {
    @Autowired
    private RedisTemplate<String, String> redisTemplate;
    @Autowired
    private PsUserInfoMapper psUserInfoMapper;
    @Autowired
    private SelfUserDetailsService userDetailsService;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registry1 = registry.addInterceptor(new AuthorizationInterceptor(redisTemplate, psUserInfoMapper, userDetailsService));
        registry1.addPathPatterns("/**");
        registry1.excludePathPatterns("/**/*.html");
        registry1.excludePathPatterns("/**/*.js");
        registry1.excludePathPatterns("/**/*.css");
    }
}
